﻿/*
 *********************************************************************
 *    Management Extensions for Windows Windows Server AppFabric     *
 *********************************************************************
 *    Author    : Fatih Boy [fatih@enterprisecoding.com]             *
 *    Web site  : http://www.enterprisecoding.com                    *
 *********************************************************************
 *    License   : GNU Library General Public License (LGPL)          * 
 *********************************************************************
 */

using Microsoft.Web.Management.Server;
using System;

namespace Com.Enterprisecoding.AppFabric.Extensions.Services {
    internal abstract class ChildServiceBase : ModuleService {
        public object InvokeMethod(string methodName, params object[] parameters) {
            var types = new Type[parameters.Length];

            for (int i = 0; i < parameters.Length; i++) {
                types[i] = parameters[i].GetType();
            }

            var methodInfo = GetType().GetMethod(methodName, types);

            if (methodInfo == null) { return null; }

            return methodInfo.Invoke(this, parameters);
        }
    }
}